﻿using System;
using UnityEngine;
using UnityEngine.Events;

// Token: 0x02000227 RID: 551
public class H_Map : MonoBehaviour
{
	// Token: 0x06000ED4 RID: 3796 RVA: 0x0005CD78 File Offset: 0x0005AF78
	private void Start()
	{
		int mapNum = GlobalData.GetMapNum();
		for (int i = 0; i < mapNum; i++)
		{
			this.CreateToggleButton(GlobalData.GetMapShowName(i), this.place);
		}
		RadioButtonGroup radioButtonGroup = this.SetupRadioButtonGroup(this.place.gameObject, false);
		radioButtonGroup.Value = GlobalData.PlayData.lastSelectMap;
		radioButtonGroup.action.AddListener(new UnityAction<int>(this.ChangeMap));
		this.CreateToggleButton("昼", this.timeZone);
		this.CreateToggleButton("夕", this.timeZone);
		this.CreateToggleButton("夜(点灯)", this.timeZone);
		this.CreateToggleButton("夜(消灯)", this.timeZone);
		RadioButtonGroup radioButtonGroup2 = this.SetupRadioButtonGroup(this.timeZone.gameObject, false);
		radioButtonGroup2.Value = GlobalData.PlayData.lastSelectTimeZone;
		radioButtonGroup2.action.AddListener(new UnityAction<int>(this.ChangeTimeZone));
	}

	// Token: 0x06000ED5 RID: 3797 RVA: 0x0005CE6C File Offset: 0x0005B06C
	private ToggleButton CreateToggleButton(string title, Transform parent)
	{
		ToggleButton toggleButton = UnityEngine.Object.Instantiate<ToggleButton>(this.originalToggle);
		toggleButton.SetText(title, title);
		toggleButton.transform.SetParent(parent, false);
		return toggleButton;
	}

	// Token: 0x06000ED6 RID: 3798 RVA: 0x0005CE9C File Offset: 0x0005B09C
	private RadioButtonGroup SetupRadioButtonGroup(GameObject go, bool allowOff)
	{
		RadioButtonGroup radioButtonGroup = go.GetComponent<RadioButtonGroup>();
		if (radioButtonGroup == null)
		{
			radioButtonGroup = go.AddComponent<RadioButtonGroup>();
		}
		radioButtonGroup.AllowOFF = allowOff;
		ToggleButton[] componentsInChildren = go.GetComponentsInChildren<ToggleButton>();
		radioButtonGroup.SetToggleButtons(componentsInChildren);
		return radioButtonGroup;
	}

	// Token: 0x06000ED7 RID: 3799 RVA: 0x0005CEDC File Offset: 0x0005B0DC
	private void ChangeMap(int no)
	{
		if (GlobalData.PlayData.lastSelectMap == no)
		{
			return;
		}
		SystemSE.Play(SystemSE.SE.CHOICE);
		GlobalData.PlayData.lastSelectMap = no;
		this.Change(false);
	}

	// Token: 0x06000ED8 RID: 3800 RVA: 0x0005CF08 File Offset: 0x0005B108
	private void ChangeTimeZone(int no)
	{
		if (GlobalData.PlayData.lastSelectTimeZone == no)
		{
			return;
		}
		SystemSE.Play(SystemSE.SE.CHOICE);
		GlobalData.PlayData.lastSelectTimeZone = no;
		this.Change(true);
	}

	// Token: 0x06000ED9 RID: 3801 RVA: 0x0005CF34 File Offset: 0x0005B134
	private void Change(bool changeTimeOnly)
	{
		this.h_scene.LoadMap(changeTimeOnly);
		Resources.UnloadUnusedAssets();
	}

	// Token: 0x04000F8B RID: 3979
	[SerializeField]
	private H_Scene h_scene;

	// Token: 0x04000F8C RID: 3980
	[SerializeField]
	private Transform place;

	// Token: 0x04000F8D RID: 3981
	[SerializeField]
	private Transform timeZone;

	// Token: 0x04000F8E RID: 3982
	[SerializeField]
	private ToggleButton originalToggle;
}
